package com.human.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.human.entity.Emprp;
import com.human.entity.ResultVo;
import com.human.service.IEmprpService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 员工奖惩情况 前端控制器
 * </p>
 *
 * @author jzq
 * @since 2023-02-28
 */
@RestController
@RequestMapping("/api/emprp")
@Api(tags = "员工奖惩管理")
@ApiSupport(order = 2)
public class EmprpController {

    @Autowired
    IEmprpService emprpService;

    @PostMapping("/page")
    @ApiOperation(value = "查询员工奖惩")
    public ResultVo<Page> page(int current, int pageSize, String name) {
        return emprpService.page(current, pageSize, name);
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "根据ID查询奖惩")
    public ResultVo getEmprpById(@PathVariable("id") Integer id) {
        return emprpService.getEmprpById(id);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("根据ID删除奖惩")
    public ResultVo<String> deleteEmprpById(@PathVariable("id") Integer id) {
        boolean flag = emprpService.removeById(id);
        if (flag) {
            return new ResultVo<>(true, "删除成功");
        }
        return new ResultVo<>(false, "删除失败");
    }

    @PostMapping("/addEmprp")
    @ApiOperation(value = "添加奖惩")
    public ResultVo addEmprp(@RequestBody Emprp emprp) {
       return emprpService.addEmprp(emprp);
    }

    @PutMapping("/updateEmprp")
    @ApiOperation(value = "修改奖惩")
    public ResultVo updateEmprp(@RequestBody Emprp emprp){
        return emprpService.updateEmprp(emprp);
    }

}

